[feature] SC-166737/improve app proxy security by restricting where token replacements can go#120
Conversation
…oken replacements can go
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR enhances the HubSpot integration by enabling dynamic credential injection into API requests through a new settingsInjection configuration in manifest.json and by enforcing immutability for core constant objects with Class diagram for updated HubSpot constants with immutabilityclassDiagram
class placeholders {
<<const>>
API_TOKEN: "__api_token__"
OAUTH2_ACCESS_TOKEN_PATH: "oauth2/access_token"
OAUTH2_REFRESH_TOKEN_PATH: "oauth2/refresh_token"
}
class PROPERTIES {
<<const>>
contacts: ["firstname", "lastname", "email", "phone", "lifecyclestage"]
companies: ["name"]
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Add runtime validation for the new settingsInjection config so missing or malformed credentials are caught early with clear errors before proxy requests are made.
- Include unit tests specifically for settingsInjection to verify that tokens are only injected into the designated body fields and headers on the allowed endpoints.
- Consider exposing explicit TypeScript types (e.g. via unions or helper interfaces) derived from your
as constplaceholders and PROPERTIES so downstream code can only use valid values.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add runtime validation for the new settingsInjection config so missing or malformed credentials are caught early with clear errors before proxy requests are made.
- Include unit tests specifically for settingsInjection to verify that tokens are only injected into the designated body fields and headers on the allowed endpoints.
- Consider exposing explicit TypeScript types (e.g. via unions or helper interfaces) derived from your `as const` placeholders and PROPERTIES so downstream code can only use valid values.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances security for the HubSpot app by implementing strict controls on credential injection and improving type safety for constant objects.
- Adds
settingsInjectionconfiguration to restrict where HubSpot credentials can be injected in API requests - Applies
as constassertions to constant objects for immutability and better type inference
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| manifest.json | Adds settingsInjection configuration to the proxy whitelist, restricting client_id and client_secret to request bodies and api_token to the Authorization header |
| src/services/hubspot/constants.ts | Applies as const assertions to placeholders and PROPERTIES objects to enforce immutability and improve type safety |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Build for commit 36b985d deployed to: https://hubspot-pr-120.ci.next.deskprodemo.com URLs: |
This pull request introduces improvements to the handling of HubSpot API authentication and constants in the codebase. The main focus is on enhancing configuration flexibility and enforcing immutability for constant objects.
Authentication and configuration enhancements:
manifest.jsonto support dynamic injection of credentials (client_id,client_secret, andapi_token) into request bodies and headers via the newsettingsInjectionproperty.Codebase consistency and safety:
placeholdersandPROPERTIESconstant objects insrc/services/hubspot/constants.tsto use theas constassertion, ensuring that these objects are treated as immutable and their values are inferred as literal types. [1] [2]Summary by Sourcery
Improve app proxy security by configuring explicit credential injection points in the manifest and enforcing immutability of HubSpot constants
New Features:
Enhancements: